package com.cy.pj.goods.service.impl;

import com.cy.pj.goods.dao.GoodsDao;
import com.cy.pj.goods.service.GoodsService;
import com.cy.pj.goods.pojo.Goods;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    //获取一个日志对象(推荐使用slf4j-simple loging facade for java包中的日志对象-因为这是规范(Logger))(Logger是接口)
    private static final Logger log= //import org.slf4j.Logger; (支持log4j,logback)
            LoggerFactory.getLogger(GoodsServiceImpl.class);//import org.slf4j.LoggerFactory;
    @Autowired
    public GoodsDao goodsDao;

    @Override
    public int updateGoods(Goods goods) {
        return goodsDao.updateGoods(goods);
    }

    @Override
    public Goods findById(Integer id) {
        return goodsDao.findById(id);
    }

    @Override
    public int saveGoods(Goods goods) {
        return goodsDao.insertGoods(goods);
    }

    @Override
    public List<Goods> findGoods(String name){
        List<Goods> list = goodsDao.findGoods(name);
        return list;
    }

    @Override
    public int deleteById(Integer id) {
        int rows = goodsDao.deleteById(id);
        return rows;
    }
}
